$(function () {
    $("#page").load("/html/page.html");
});
function findAll() {
    let data = {
        name: $("#name").val(),
        status:$("#type").find("option:selected").val() ,
        pageSize: $.trim($("#pageSize").val()),
        pageNum: $.trim($("#pageNum").val()),
    }
    let result = myAjax('/d/daily/searchAll','post',data);
    if (result.code===200){
        show(result.data.list);
        $("#pageCount").html(result.data.number);
    }else {
        layer.msg(result.message);
    }
}
function show(data) {
 let html = "";
 for (let i=0;i<data.length;i++){
     if (data[i].status==null){
         data[i].status="未审核";
         html += '   <tr> ' +
             '  <td><input type="checkbox" name="isCheck" value="' + data[i].id + '">' + data[i].id + '</td>\n' +
             '        <td>' + data[i].name + '</td>\n' +
             '        <td>' + data[i].classTeacher + '</td>\n' +
             '        <td>' + data[i].coach + '</td>\n' +
             '        <td>' + data[i].writeTime + '</td>\n' +
             '        <td style="color: red">' + data[i].status+ '</td>\n' +
             '        <td><input type="button" style="width: 80px;border-radius: 5px;' +
             'background-color: #37905a" value="立即审核" onclick="audit(' + data[i].id + ')"></td>' +
             '    </tr>';
     }else if (data[i].status===1){
         data[i].status="已审核";
         html += '   <tr> ' +
             '  <td><input type="checkbox" name="isCheck" value="' + data[i].id + '">' + data[i].id + '</td>\n' +
             '        <td>' + data[i].name + '</td>\n' +
             '        <td>' + data[i].classTeacher + '</td>\n' +
             '        <td>' + data[i].coach + '</td>\n' +
             '        <td>' + data[i].writeTime + '</td>\n' +
             '        <td style="color: green">' + data[i].status + '</td>\n' +
             '        <td><input type="button" style="width: 80px;border-radius: 5px;' +
             'background-color: #d0c34b" value="查看" onclick="look(' + data[i].id + ')"></td>' +
             '    </tr>';
     }
 }
 $("#findAll").html(html);
}
layui.use("layer");
function audit(id) {
    sessionStorage.setItem("dailyId",id);
    layer.open({
        type: 2,
        anim: 1,
        title: "审核日报",
        area: ['800px', '750px'],
        shadeClose: true, //点击遮罩关闭
        content: ['/html/daily/auditAtOnce.html', 'no'],
    })
}
function look(id) {
   sessionStorage.setItem("dailyId",id);
    layer.open({
        type: 2,
        anim: 1,
        title: "查看日报",
        area: ['800px', '750px'],
        shadeClose: true, //点击遮罩关闭
        content: ['/html/daily/lookDaily.html', 'no'],
    })
}